/*
子进程

process::Output 结构体表示已结束的子进程（child process）的输出
process::Command 结构体是一个进程创建者（process builder）
*/
use std::process::Command;

fn main() {
    let output = Command::new("rustc")
        //.arg("--version1")
        .arg("--version")
        .output().unwrap_or_else(|e| {
            panic!("Failed to execute process: {}", e)
    });

    if output.status.success() {
        let s = String::from_utf8_lossy(&output.stdout);

        println!("rustc succeeded and stdout was:\n{}", s);
    } else {
        let s = String::from_utf8_lossy(&output.stderr);
        println!("rustc failed and stderr was:\n{}", s);
    }
}